package com.taxshare.seller.controller;

import cn.hutool.core.collection.CollUtil;
import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.pvalidate.ParamValid;
import com.taxshare.response.beans.Response;
import com.taxshare.seller.service.CarGoodsManageService;
import com.taxshare.seller.view.dto.CarCategoryDTO;
import com.taxshare.seller.view.dto.CarGoodsManageDTO;
import com.taxshare.seller.view.dto.TaxComplilationDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author cxl
 * @date 2021/8/19 13:15
 */
@RestController
@RequestMapping("/carGoodsManage")
@Api(tags = "机动车商品信息")
public class CarGoodsManageController {

    @Autowired
    CarGoodsManageService carGoodsManageService;

    @PostMapping("/add")
    @ApiOperation(value = "机动车商品信息新增", notes = "机动车商品管理")
    @ParamValid
    public Response addCarGoods(@RequestBody @Valid CarGoodsManageDTO goodsManageDTO) {
        return carGoodsManageService.addCarGoods(goodsManageDTO);
    }

    @GetMapping("/remove")
    @ApiOperation(value = "机动车商品信息删除", notes = "机动车商品管理")
    public Response removeCarGoods(String[] ids) {

        return carGoodsManageService.removeCarGoods(CollUtil.toList(ids));
    }

    @PostMapping("/edit")
    @ApiOperation(value = "机动车商品信息编辑", notes = "机动车商品管理")
    public Response editCarGoods(@RequestBody CarGoodsManageDTO goodsManageDTO) {
        return carGoodsManageService.editCarGoods(goodsManageDTO);
    }

    @PostMapping("/query")
    @ApiOperation(value = "机动车商品信息查询", notes = "机动车商品管理")
    public Response goodsManageQuery(@RequestBody PageRequest<TaxComplilationDTO> query) {
        return carGoodsManageService.pageCarGoods(query);
    }
}
